import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/user/LoginView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'login',
    component: Login
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/user/LoginView.vue')
  },
  {
    path: '/index',
    name: 'index',
    component: () => import('../views/book/IndexView.vue'),
    children: [
      {
        path: '',
        name: 'userindex',
        component: () => import('../views/book/UserIndex.vue'),
      },
      {
        path: 'borrow',
        name: 'borrow',
        component: () => import('../components/BorrowBook.vue'),
      },
      {
        path: 'list',
        name: 'list',
        component: () => import('../components/BorrowList.vue'),
      },
      {
        path: 'person',
        name: 'person',
        component: () => import('../components/PersonalInformation.vue'),
      }
    ]
  },
  {
    path: '/regist',
    name: 'regist',
    component: () => import('../views/user/RegistView.vue')
  },
  {
    path: '/admin',
    name: 'admin',
    component: () => import('../views/user/AdminLogin.vue')
  },
  {
    path: '/admindex',
    name: 'admindex',
    component: () => import('../views/book/AdminView.vue'),
    children:[
      {
        path: '',
        name: 'adminindex',
        component: () => import('../views/book/AdminIndex.vue'),
      },
      {
        path: 'booklist',
        name: 'booklist',
        component: () => import('../components/admin/BookList.vue'),
      },
      {
        path: 'bookadd',
        name: 'bookadd',
        component: () => import('../components/admin/BookAdd.vue'),
      },
      {
        path: 'booktype',
        name: 'booktype',
        component: () => import('../components/admin/BookType.vue'),
      },
      {
        path: 'userlist',
        name: 'userlist',
        component: () => import('../components/admin/UserList.vue'),
      },
      {
        path: 'adminlist',
        name: 'adminlist',
        component: () => import('../components/admin/AdminList.vue'),
      },
      {
        path: 'borrowlist',
        name: 'borrowlist',
        component: () => import('../components/admin/BorrowList.vue'),
      },
      {
        path: 'auditlist',
        name: 'auditlist',
        component: () => import('../components/admin/AuditList.vue'),
      },
    ]
  },
]
/* 导航守卫，路由守卫 */
/* router.beforeEach((to, from, next) => {
  if(to.path == from.path){
    return
  }else{
    next()
  } 
}) */


const router = new VueRouter({
  routes
})

export default router
